# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     job_education
   Description :
   Author :       Flyoung
   date：          2023/9/5
-------------------------------------------------
   Change Activity:
                   2023/9/5:
-------------------------------------------------
"""
from sqlalchemy import Column, Integer, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session

from db.common import with_session

Base = declarative_base()


class JobEducation(Base):
    __tablename__ = 'job_education'

    job_education_id = Column(Integer, primary_key=True, autoincrement=True)
    job_id = Column(Integer)
    education_id = Column(Integer)

    def __init__(self, job_id, education_id):
        self.job_id = job_id
        self.education_id = education_id

    def to_dict(self):
        return {
            'job_education_id': self.job_education_id,
            'job_id': self.job_id,
            'education_id': self.education_id
        }


@with_session
def add_job_education(session: Session, job_id, education_id):
    je = JobEducation(job_id, education_id)
    session.add(je)
    return je.to_dict()
